Page({
  t: wx.createInnerAudioContext(),
  data: {
    bgimg: "3",
    src: "/pages/happyTools/audio/hairClipper/1.mp3",
    src2: "/pages/happyTools/audio/hairClipper/2.mp3",
  },
  onReady: function () {
    wx.showToast({
      title: "请按开关",
      icon: "none"
    });
    this.t.obeyMuteSwitch = false
    this.t.autoplay = false
    this.t.onEnded(() => {
      console.log('音频停止了')
      if (this.data.bgimg !== "3") {
        this.t.play()
      }
    })
  },
  start: function () {
    wx.vibrateLong({
      fail: err => console.error('当前设备不支持设置震动等级', err)
    });
    this.data.bgimg === '3' ? (this.setData({
      bgimg: '2',
    }), this.t.stop(), this.t.src = this.data.src2, this.t.play()) : this.data.bgimg === '2' ? (this.setData({
      bgimg: '1',
    }), this.t.stop(), this.t.src = this.data.src, this.t.play()) : (this.setData({
      bgimg: '3',
    }), this.t.stop())
  },
  onUnload: function () {
    this.t.stop();
  },
  onShareAppMessage() {
    return {
      title: "恶搞理发器",
      path: "/pages/happyTools/pages/hairClipper/index",
      imageUrl: '/images/function_icon/hairClipper.png',
    }
  },
  onShareTimeline() {
    return {
      title: '恶搞理发器',
      imageUrl: '/images/function_icon/hairClipper.png',
    }
  },

});